package com.example.ByteStream;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 文件字节输出流FileOututStream的使用
 * @date 2023-12-11 15:26
 */
public class FileOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        //1.创建字节输出流对象
        FileOutputStream fos = new FileOutputStream("d:\\bb.txt");//覆盖写入
        FileOutputStream fos01 = new FileOutputStream("d:\\bb.txt", true);//追加写入
        //2.写入文件
        //2.1单个字符
        fos.write(97);
        fos.write('b');
        fos.write('c');
        //2.2多个字符
        String s = "helloworld";
        fos.write(s.getBytes());
        //3.关闭文件
        fos.close();
        System.out.println("执行完毕");

    }
}
